package com.ruiysoft.controller.integral;

import com.ruiysoft.controller.integral.vo.IntegralTradeVo;
import com.ruiysoft.pub.core.Result;
import com.ruiysoft.pub.core.ResultGenerator;
import com.ruiysoft.service.integral.IIntegralCurrentService;
import com.ruiysoft.service.integral.IIntegralService;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-13T19:28:15.988+08:00")

@RestController
public class InnrIntegralApiController implements InnrIntegralApi {

    private static final Logger log = LoggerFactory.getLogger(InnrIntegralApiController.class);

    private final IIntegralService integralService;
    private final IIntegralCurrentService integralCurrentService;

    @org.springframework.beans.factory.annotation.Autowired
    public InnrIntegralApiController(IIntegralService integralService, IIntegralCurrentService integralCurrentService) {
        this.integralService = integralService;
        this.integralCurrentService = integralCurrentService;
    }

    @Override
    public Result<Void> innrIntegralConsumePost(@ApiParam(value = ""  )  @Valid @RequestBody IntegralTradeVo body) {
        integralService.consume(body.getShopId(),body.getUserId(),body.getIntegral(),body.getTradeNo());
        return ResultGenerator.genSuccessResult();
    }

    @Override
    public Result<Void> innrIntegralRefundPost(@ApiParam(value = ""  )  @Valid @RequestBody IntegralTradeVo body) {
        integralService.refund(body.getShopId(),body.getUserId(),body.getIntegral(),body.getTradeNo());
        return ResultGenerator.genSuccessResult();
    }

}
